package data_structure;

public class comparable {
    public static void main(String[] args) {
        //使用已经实现comparable的类的对象（String类型），比较大小
        String s = "hello";
        String t = "world";
        //比较s和t得大小
        int cmp = s.compareTo(t);
        if(cmp < 0 ){
            System.out.println("hello小于world");
        } else if (cmp == 0) {
            System.out.println("hello等于world");
        }else {
            System.out.println("hello小于world");
        }
    }
}
